package com.my.blog.myblog.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.my.blog.annotation.SystemLog;
import com.my.blog.utils.ConstantUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/***
 *
 * @Auther: MuYun
 * @Date: 2021/8/11 17:42
 * @Description：
 *
 */
@Controller
public class IndexController {

    //首页
    @RequestMapping(value = {"/","/index"})
    public ModelAndView index(){
        return new ModelAndView("page/index");
    }

    //技术博客
    @RequestMapping("/list")
    public ModelAndView list(){
        return new ModelAndView("page/list");
    }

    //技术专栏
    @GetMapping("/result")
    public ModelAndView result(@RequestParam(value = "keyboard",required = false) String keyboard){
        ModelAndView mv=new ModelAndView();
        mv.addObject("keyword",keyboard);
        mv.setViewName("page/result");
        return mv;
    }

    //资源分享
    @GetMapping("/resource")
    public ModelAndView resource(){
        return new ModelAndView("page/resource");
    }

    //介绍
    @GetMapping("/intro")
    public ModelAndView intro(){
        return new ModelAndView("page/intro");
    }

    //关于我
    @GetMapping("/about")
    public ModelAndView about(){
        return new ModelAndView("page/about");
    }

    //留言
    @GetMapping("/message")
    public ModelAndView message(){
        return new ModelAndView("page/message");
    }

    //进入后台
    @GetMapping("/admin")
    public ModelAndView admin(){
        System.out.println("去后台....");
        return new ModelAndView("admin/index");
    }

    //跳转至登录页
    @GetMapping("/login")
    public ModelAndView login(){
        return new ModelAndView("login");
    }
    //清除cookie并退出
    @GetMapping("/logout")
    public ModelAndView logout(){
        StpUtil.logout();
        return new ModelAndView("page/index");
    }
}
